# @author zfd
# @date 2022年12月13日 14:16
# @desc 对象的浅拷贝和深拷贝

class CPU:
    pass


class Disk:
    pass


class Computer:
    def __init__(self, cpu, disk):
        self.cpu = cpu
        self.disk = disk


#
print('变量的引用赋值---')
c1 = CPU()
c2 = c1
print(c1, id(c1))
print(c2, id(c2))
print(c1 == c2)
print('------------')
d = Disk()
cp = Computer(c1, d)

# 浅拷贝
print('------------浅拷贝')
import copy

print(d, id(d))
cp2 = copy.copy(cp)
print(cp, cp.cpu, cp.disk)
print(cp2, cp2.cpu, cp2.disk)

print('------------深拷贝')
cp3 = copy.deepcopy(cp)
print(cp, cp.cpu, cp.disk)
print(cp3, cp3.cpu, cp3.disk)
